asynx.impl.lang = {
	
	trim: function(s){
        try {
            return s.replace(/^\s+|\s+$/g, "");
        } catch(e) {
            return s;
        }
    },
	
	/**
	 * Adds escape sequences for non-visual characters, double quote and backslash
	 * and surrounds with double quotes to form a valid string literal.
	 * @param {String} str
	 */
	escape: function(str) {
		return str.replace(/[\\]/g, "\\\\")
			.replace(/[\"]/g, '\\"')
			.replace(/[\n]/g, '\\n')
			.replace(/[\r]/g, '\\r');
	},
	
	isArray: function(el) {
		return el && el.constructor==Array;
	},
	
    isFunction: function(o) {
        return typeof o === 'function';
    },
	
	isArray: function(o) { 
        if (o) {
           return asynx.isNumber(o.length) && asynx.isFunction(o.splice) && 
                  !asynx.hasOwnProperty(o.length);
        }
        return false;
    },

	isObject: function(o) {
		return (o && (typeof o === 'object' || asynx.isFunction(o))) || false;
    },
	
	isBoolean: function(o) {
        return typeof o === 'boolean';
    },
	
    isUndef: function(o) {
        return typeof o === 'undefined';
    },
	
	isEmpty: function(v) {
		return v === "";
	},
	
	isXMLDoc: function(el) {
		return el.tagName && el.ownerDocument && !el.ownerDocument.body;
	},
	
    isString: function(o) {
        return typeof o === 'string';
    },
	
	isNumber: function(o) {
        return typeof o === 'number' && isFinite(o);
    },
	
	isNull: function(o) {
        return o === null;
    },
	
	hasOwnProperty: function(o, prop) {
        if (Object.prototype.hasOwnProperty) {
            return o.hasOwnProperty(prop);
        }
        return !asynx.isUndef(o[prop]) && 
                o.constructor.prototype[prop] !== o[prop];
    }
	
};

asynx.extend(asynx, asynx.impl.lang);
delete asynx.impl.lang;
